package io.renren.modules.jxgkphone.controller;


import io.renren.common.utils.R;
import io.renren.modules.jxgkphone.entity.DateInfo;
import io.renren.modules.jxgkphone.service.ClassCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/course")
public class ClassCourseController {

    @Autowired
    ClassCourseService classCourseService;

    @RequestMapping("/{classid}/ClassWeekCourse")
    public List getClassCourse(@RequestBody DateInfo date, @PathVariable("classid") String classid) {
        List ls =new ArrayList();
        ls = classCourseService.getWeekCourse(date, classid);
        return ls;
    }

    @RequestMapping("/ClassTeacherWeekCourse")
    public List getClassTeacherWeekCourse(@RequestBody DateInfo date) {
        List ls = classCourseService.getClassTeacherWeekCourse(date);
        return ls;
    }

    @RequestMapping("/getThisTerm")
    public R getThisTerm() {
       List<Integer> list= classCourseService.getThisTerm();
        return R.ok().put("term", list.get(0));
    }

    @RequestMapping("/getCourseByClass")
    public R getCourseByClass(@RequestParam Map<String, Object> params) {
        List ls =new ArrayList();
        ls = classCourseService.getCourseByClass(params);
        return R.ok().put("list",ls);
    }
    @RequestMapping("/{date}/{classid}/ClassDayCourse")
    public List getDayCourse(@PathVariable("date") String date, @PathVariable("classid") String classid) {
        List ls =new ArrayList();
        ls=classCourseService.getDayCourse(date, classid);
        if(ls.isEmpty())
            return null;
        return ls;
    }
    @RequestMapping("/{classid}/ClassDiaryDayCourse")
    public List getDiaryDayCourse(@PathVariable("classid")String classid){
        List ls =new ArrayList();
        ls=classCourseService.getDiaryDayCourse(classid);
        return ls;
    }
    @RequestMapping("/{classid}/ClassAttendanceDayCourse")
    public List getAttendanceDayCourse(@PathVariable("classid")String classid){
        List ls =new ArrayList();
        ls=classCourseService.getAttendanceDayCourse(classid);
        return ls;
    }

    @RequestMapping("/{date}/ClassTeacherDayCourse")
    public List getTeacherDayCourse(@PathVariable("date") String date) {
        List ls = classCourseService.getTeacherDayCourse(date);
        return ls;
    }

}